package com.infore.statisticsAndAlarm.service.impl;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import com.infore.statisticsAndAlarm.bo.DatasChartsBo;
import com.infore.statisticsAndAlarm.constant.CheckingConstants;
import com.infore.statisticsAndAlarm.enums.ResultStatus;
import com.infore.statisticsAndAlarm.enums.WaterQualityTargetLevel;
import com.infore.statisticsAndAlarm.service.ICheckingDatasService;
import com.infore.statisticsAndAlarm.util.ResultEntity;

@Service
public class CheckingDatasServiceImpl implements ICheckingDatasService {

	public ResultEntity ckeckingDatasChartsBo(DatasChartsBo bo) {
		String flag = "success";
		String stationCode = bo.getStationCode();// 站点编码（mn）
		String factorCode = bo.getFactorCode();// 因子参数
		String startTime = bo.getStartTime();// 开始时间
		String endTime = bo.getEndTime();// 结束时间
		String startQuarter = bo.getStartQuarter();// 季度 按季度查询时使用
		String endQuarter = bo.getEndQuarter();// 季度 按季度查询时使用
		String type = bo.getType();// 时间类别---hour（小时)----day（天）---month（月）---quarter（季度）---year（年份）
		if (StringUtils.isBlank(type)) {
			flag = CheckingConstants.TYPE;
			return new ResultEntity(ResultStatus.SUCCESS, flag);
		}
		if ("hour".equals(type) || "day".equals(type) || "month".equals(type) || "year".equals(type)) {
			if (StringUtils.isBlank(stationCode)) {
				flag = CheckingConstants.STATIONCODE;
				return new ResultEntity(ResultStatus.SUCCESS, flag);
			} else if (StringUtils.isBlank(factorCode)) {
				flag = CheckingConstants.FACTORCODE;
				return new ResultEntity(ResultStatus.SUCCESS, flag);
			} else if (StringUtils.isBlank(startTime)) {
				flag = CheckingConstants.STARTTIME;
				return new ResultEntity(ResultStatus.SUCCESS, flag);
			} else if (StringUtils.isBlank(endTime)) {
				flag = CheckingConstants.ENDTIME;
				return new ResultEntity(ResultStatus.SUCCESS, flag);
			}
		} else if ("quarter".equals(type)) {
			if (StringUtils.isBlank(startQuarter)) {
				flag = CheckingConstants.STARTQUARTER;
				return new ResultEntity(ResultStatus.SUCCESS, flag);
			} else if (StringUtils.isBlank(endQuarter)) {
				flag = CheckingConstants.ENDQUARTER;
				return new ResultEntity(ResultStatus.SUCCESS, flag);
			} else if (StringUtils.isBlank(startTime)) {
				flag = CheckingConstants.STARTTIME;
				return new ResultEntity(ResultStatus.SUCCESS, flag);
			} else if (StringUtils.isBlank(endTime)) {
				flag = CheckingConstants.ENDTIME;
				return new ResultEntity(ResultStatus.SUCCESS, flag);
			}
		}
		return new ResultEntity(ResultStatus.SUCCESS, flag);
	}

	public Map<String, String> queryTargetLevel() {
		Map<String, String> map = new HashMap<String, String>();
		for (WaterQualityTargetLevel e : WaterQualityTargetLevel.values()) {
			map.put(e.getStatusCode(), e.getReasonPhrase());
		}
		return map;
	}

	public Map<String, String> queryTargetLeveltoNumber() {
		Map<String, String> map = new HashMap<String, String>();
		for (WaterQualityTargetLevel e : WaterQualityTargetLevel.values()) {
			map.put(e.getReasonPhrase(), e.getStatusCode());
		}
		return map;
	}

	public ResultEntity checkMnCodeAndResult(String mn, String code, Object object) {
		if (StringUtils.isBlank(mn) || StringUtils.isBlank(code) || object == null) {

		}
		return null;
	}

}
